<template>
  <page-form :x-uri="uri" :x-tabs="tabs" reset-btn-text="撤销修改" :bind-rules="rules" :custom-components="custom" />
</template>

<script>
import PageForm from '@public/template/page_form.vue';
import DateTime from './components/time.vue';
import Attach from './components/attach.vue';
import CourseChoose from './components/course_choose.vue';
import Completion from './components/completion';

export default {
  components: {
    PageForm
  },
  data() {
    return {
      uri: '/course/admin/live/' + this.$route.params.id + '/section/' + this.$route.params.sid + '/edit',
      tabs: [
        {
          title: '大班课列表',
          uri: '/course/live/list',
          meta: {
            permission: 'course.live.large'
          }
        },
        {
          title: '课时列表',
          uri: '/course/live/' + this.$route.params.id + '/section',
          meta: {
            permission: 'course.live.large.section'
          }
        },
        {
          title: '编辑课时',
          uri: '/course/live/' + this.$route.params.id + '/section/' + this.$route.params.sid + '/edit',
          meta: {
            permission: 'course.live.large.section'
          }
        }
      ],
      custom: {
        time: DateTime,
        course_ids: CourseChoose,
        playback_id: Attach,
        completion_conditions: Completion
      },
      rules: {
        audition: [
          {
            validator: (rule, value, callback) => {
              const reg = /^([1-9]?\d|100)$/;
              if (!reg.test(value)) {
                return callback(new Error('必须为0-100的整数'));
              }
              callback();
            },
            trigger: ['blur', 'change']
          }
        ]
      }
    };
  }
};
</script>
